<link rel="stylesheet" type="text/css" href="/public/static/css/index.css" />
<script src="/public/static/js/synchro.js"></script>
<{include file="tpl/filter.tpl"}>

<div>
    <a class="label-success pull-right" style="color: #fff; padding: 0 4px;" href="<{PubFunc::buildUrl('/oss/?r=settingSpecial/add')}>">
        <i class="fa fa-plus"></i> 添加专服配置(热更)
    </a>
    <input class="label-success pull-left" type="checkbox" id="all" />&nbsp;<span id="aa">全选</span>
    <a href="javascript:;" id="synSpecial_batch" name="synSpecial_batch" class="btn" style="margin-right: -5px;margin-bottom: 5px;" data-url="?r=settingSpecial/synSpecial">同步</a>	
</div>

<{include file="tpl/grid.tpl"}>
	
<script>
	    $(document).on('click','a[name="synSpecial_one"]',function(){
	    	var ids = $(this).attr('data-id'); 
            synSpecial(ids);      	
        }); 
        
        
        $('a[name="synSpecial_batch"]').click(function(){
        	var arr = new Array();
            $("input[name='id']:checkbox[checked]").each(function(i){
                arr[i] = $(this).val();
            });
            var ids = arr.join(",");
            if(ids == ""){
            	layer.msg('请先选择要操作的数据！', {icon: 2,time: 3000});
            	return false;
            }
            synSpecial(ids);
        });
        
        function synSpecial(ids){
        	layer.confirm('确定进行同步？', {
        		btn: ['确定','取消'] //按钮
            }, function(){
            	var uploading = layer.load(2, {shade: [0.4, '#393D49']});
            	var data_url = $('a[name="synSpecial_batch"]').attr('data-url');
                var g = $("input[name='g']").val();
                var url = data_url+'&g='+g;
                
                $.ajax({
                   	type : 'POST',
    		        url : url,
			        data : {'ids':ids,},
			        dataType :'JSON',
			        success : function(res){
			        	layer.close(uploading);
				        if(res.status == 1){
				        	layer.alert(res.msg, {
				        	      skin: 'layui-layer-molv' //样式类名
						          ,closeBtn: 0
					            }, function(){
						          window.location.reload();
					            }); 
				        }else{
					        layer.alert(res.msg, {icon: 2, skin: 'layui-layer-molv'});
				        }
			        }
		        });	
            }, function(){
            	//取消
            });
        }
</script>